<?php
/**
 * Created by PhpStorm.
 * User: happy
 * Date: 17/8/17
 * Time: 上午11:11
 */
class client{
  private  $client;
    public  function  __construct(){
        $this->client=new swoole_client(SWOOLE_SOCK_TCP);
    }
    public  function  connect(){
        if(!$this->client->connect('127.0.0.1','9501',1)){
            echo "Error:".$this->client->errMsg.'  '.$this->client->errCode;
        }
        fwrite(STDOUT,"请输入消息 please input msg:");
        $msg=trim(fgets(STDIN));
        $this->client->send($msg);
        $message=$this->client->recv();
        echo "get message from server ".$message;
    }
}

$client=new client();
$client->connect();

